package Model;

import java.util.Date;

public class PeriodicTask extends Task
{
	private String repeat;

	/**
	 * Create a periodic task with the following parameters
	 * 
	 * @param iTaskName
	 * @param iDueDatek
	 * @param iType
	 */
	public PeriodicTask(String iTaskName, Date iDueDatek, String iType)
	{
		super(iTaskName, iDueDatek, iType);
	}

	/**
	 * Create a periodic task with the following parameters
	 * 
	 * @param iTaskName
	 * @param iDueDatek
	 * @param iType
	 * @param iPeriodFrequency
	 */
	public PeriodicTask(String iTaskName, Date iDueDatek, String iType,
	    String iPeriodFrequency)
	{
		super(iTaskName, iDueDatek, iType);
		setRepeat(iPeriodFrequency);
		super.datainterface.setFrequency(iPeriodFrequency);
	}

	/**
	 * Copy constructor
	 * 
	 * @param period
	 */
	public PeriodicTask(PeriodicTask period)
	{
		super(period.getName(), period.getDueDate(), period.getType());
	}

	/**
	 * Set the repeat interval
	 * 
	 * @param repeat
	 */
	public void setRepeat(String repeat)
	{
		this.repeat = repeat;
	}

	/**
	 * Get the repeat interval
	 * 
	 * @return
	 */
	public String getRepeat()
	{
		return this.repeat;
	}

	/**
	 * Returns the due date for single tasks, Interval for periodic tasks or
	 * "Complex" for complex tasks
	 * 
	 * @return
	 */
	public String getDateString()
	{
		return getRepeat();
	}

	/**
	 * For printing ease / debugging
	 * 
	 * @return a string representing whatever is in the task
	 */
	public String toString()
	{
		String str = new String();
		str = "[";
		str += getName();
		str += "|";
		str += getDueDate();
		str += "|";
		str += getType();
		str += "|";
		str += getRepeat();
		str += "|";
		str += getDone() ? "done" : "notdone";
		str += "]";
		return str;
	}
}
